<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
        首页
        <a href="javascript:;" id="exit">退出登录</a>
</body>
<script>
    var name=sessionStorage.getItem("username");
    var h1=document.createElement("h1");
    if(name=="null"){
        name=localStorage.getItem("username");
        if(name=="null"){
            h1.innerHTML="欢迎您，游客";
        }else{
            sessionStorage.setItem("username",name);
            h1.innerHTML="欢迎您，"+name;
        }
    }else{
        h1.innerHTML="欢迎您，"+name;
    }
    document.body.appendChild(h1);
    var exit=document.getElementById("exit");
    exit.onclick=function(){
        sessionStorage.removeItem("username");
        localStorage.removeItem("username");
        location.reload();
    }
</script>
</html>